package com.contory.ssn_lgnd.app.maingame;

import java.util.LinkedList;

import com.contory.ssn_lgnd.app.comp.DrawPtr;
import com.contory.ssn_lgnd.framework.gl.SpriteBatcher;

public class TerrainPartsGroup implements DrawPtr{
	LinkedList<TerrainParts> terrainList;
	final ColisionManager cm; 
	
	public TerrainPartsGroup(ColisionManager cm){
		terrainList = new LinkedList<TerrainParts>();
		this.cm = cm;
	}

	public void addRectTile(float strX, float strY, int w, int h){
		TerrainPartsRect chdObj = new TerrainPartsRect(strX, strY, w, h);
		terrainList.add(chdObj);
		cm.addStaticColiObj(chdObj);
	}
	
	public void addTriangleTile(float strX, float strY, int cellSize, int type){
		TerrainPartsTrianlge chdObj = new TerrainPartsTrianlge(strX, strY, cellSize, type);
		terrainList.add(chdObj);
		cm.addStaticColiObj(chdObj);
	}
	
	@Override
	public void draw(SpriteBatcher batcher) {
		for(int i = 0; i < terrainList.size(); i++){
			terrainList.get(i).draw(batcher);
		}
	}
	
	public int getSize(){
		return terrainList.size();
	}
	
	public void removeTerrain(TerrainParts parts){
		terrainList.remove(parts);
	}
	
	public void clear(){
		terrainList.clear();
		cm.staticColiOjbClear();
	}
}
